/*
 * 		CSC 660, Program # 1
 * 		Raj Akula, Rubaiyat Hossain
 * 		03/26/2012
 * 		Description: A socket-based, multithreaded server that handles simple HTTP 1.0
 * 					 requests. 
 * 					 
 */
package nku.edu.webserver;

import java.net.*;

public class WebServer
{
	public static void main(String args[])throws Exception
	{
		int portNumber=8087;
		//Declaring listening socket,  it will be listening for connection requests
		ServerSocket MyService;
		Socket serviceSocket=null;
		//Server will be listening to port number 8087. 
		MyService = new ServerSocket(portNumber);

		//server is placed in an infinte loop for listening for TCP connection requests.
		while(true)
		{
			try
			{
				//Listen for a TCP connection request.
				serviceSocket = MyService.accept();
				//Create an object to handle the HTTP requests
				HttpRequest request = new HttpRequest(serviceSocket);
				//Create a new thread to handle the request
				Thread thread = new Thread(request);
				thread.start();
			}
			catch(Exception e)
			{
				System.out.println(e);
			}
		}

	}

}

